package com.gla.dao;

import com.gla.entity.Index;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IndexMapper {
    @Select("SELECT price,id FROM COMMODITY WHERE id = ANY(SELECT commodity_id FROM ORDERDETAIL WHERE order_id = ANY(SELECT id FROM ORDERS WHERE state = 3 or state = 4))")
    List<Index> selectPriceAndId();

    @Select("SELECT number ,commodity_id AS id FROM ORDERDETAIL WHERE order_id = ANY( SELECT id FROM `ORDERS` WHERE state = 3 or state = 4)")
    List<Index> selectNumberAndId();

    @Select("SELECT id , DATE_FORMAT(create_time,'%c') AS create_time FROM `ORDERS` WHERE state = 3 OR state = 4")
    List<Index> selectTimeAndId();

    @Select("SELECT id AS order_id FROM `ORDERS` WHERE state = 3 or state = 4")
    List<Integer> selectOrder_id();

    @Select("SELECT id , DATE_FORMAT(create_time,'%c') AS create_time FROM `ORDERS` WHERE (state = 3 OR state = 4) AND date(create_time) = curdate()")
    List<Index> selectToday();
}
